import os
import sys
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *

class PPT(QWidget):

    def __init__(self):
        super(PPT, self).__init__()
        self.IMG_PATH=os.path.join(os.path.dirname(__file__),'imgs')
        self.icon_path=os.path.join(os.path.dirname(__file__),'icon.png')
        self.img_index=0
        self.all_img=0
        self.btn_style='''QPushButton{color:black}
                                      QPushButton:hover{color:red}
                                      QPushButton{background-color:#CCCCCC}
                                      QPushButton{border:2px}
                                      QPushButton{border-radius:30px}
                                      QPushButton{padding:50px 80px}
                                      QPushButton{text-align:bottom })'''
        self.setWindowTitle('小程序制作流程')
        self.setWindowIcon(QIcon(self.icon_path))
        self.main_layout=QHBoxLayout()
        self.desk=QApplication.desktop()
        self.setFixedWidth(self.desk.width())
        self.setFixedHeight(self.desk.height())
        self.show_label=QLabel('')
        self.show_label.setAlignment(Qt.AlignTop)
        self.init_img()
        self.btn_layout=QHBoxLayout()
        # self.btn_layout.setContentsMargins(0,20,0,150)
        self.back_btn=QPushButton()
        self.back_btn.clicked.connect(self.back)
        self.back_btn.setStyleSheet(self.btn_style)
        self.next_btn=QPushButton()
        self.next_btn.clicked.connect(self.next)
        self.next_btn.setStyleSheet(self.btn_style)
        self.btn_layout.addWidget(self.back_btn)
        self.btn_layout.addWidget(self.next_btn)
        self.main_layout.addWidget(self.back_btn)
        self.main_layout.addWidget(self.show_label)
        self.main_layout.addWidget(self.next_btn)

        self.setLayout(self.main_layout)

    def init_img(self):
        img0=os.path.join(self.IMG_PATH,'{}.png'.format(self.img_index))
        pix=QPixmap(img0)
        self.show_label.setPixmap(pix)
        self.all_img=len(os.listdir(self.IMG_PATH))

    def back(self):
        self.img_index=self.img_index-1 if self.img_index>0 else 0
        img_path=os.path.join(self.IMG_PATH,'{}.png'.format(self.img_index))
        pix=QPixmap(img_path)
        self.show_label.setPixmap(pix)

    def next(self):

        self.img_index=self.img_index+1 if self.img_index<self.all_img else self.all_img
        img_path=os.path.join(self.IMG_PATH,'{}.png'.format(self.img_index))
        pix=QPixmap(img_path)
        self.show_label.setPixmap(pix)


if __name__ == '__main__':
    app=QApplication(sys.argv)
    p=PPT()
    p.show()
    sys.exit(app.exec_())
